package com.jandar.config;

import com.alibaba.druid.pool.DruidDataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author : cyt
 * @date : 2019/3/11
 */
@Configuration
public class DatabaseConfig {

    private final AppConfig appConfig;

    public DatabaseConfig(AppConfig appConfig) {
        this.appConfig = appConfig;
    }

    @ConfigurationProperties(prefix = "spring.datasource.app")
    @Bean("appDataSource")
    @Primary
    public DataSource druidDataSource() {
        return new DruidDataSource();
    }

}
